package com.zs.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.zs.model.WorkOrderEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.zs.common.config.ResponseCode;
import com.zs.model.criteria.BaseCriteria;
import com.zs.service.WorkOrderService;

/**
 * 工单
 */
@Controller
@RequestMapping("/workOrder")
public class WorkOrderController {

    @Resource
    private Gson gson;

    @Resource
    private WorkOrderService workOrderService;

    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String selectWorkOrderList(HttpServletRequest request,
                                    @RequestParam(value = "pn", required = true, defaultValue = "1") Integer pageNo,
                                    @RequestParam(value = "ps", required = true, defaultValue = "3") Integer pageSize
    ) {
        BaseCriteria baseCriteria = new BaseCriteria();
        baseCriteria.setPageNo(pageNo);
        baseCriteria.setPageSize(pageSize);
        String nowDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        baseCriteria.setStartTime(nowDate+" 00:00:00");
        baseCriteria.setEndTime(nowDate+" 23:59:59");
        return workOrderService.selectWorkOrderList(baseCriteria);
    }
    

}
